//
//  HJStartPageController.m
//  KaiChat
//
//  Created by lx on 2023/10/17.
//

#import "HJStartPageController.h"
#import "HJMinePresent.h"
#import "HJJsonAnimationView.h"
 

@interface HJStartPageController ()

@property (nonatomic, weak) HJJsonAnimationView *animationView;

@end

@implementation HJStartPageController

- (void)viewDidLoad {
    [super viewDidLoad];
 
    HJJsonAnimationView *animationView = [[HJJsonAnimationView alloc] initWithName:@"startPage"];
    animationView.isLastFrame = YES;
    [self.view addSubview:animationView];
    [animationView addTapGesturesWithTarget:self action:@selector(tapJsonAnimationView)];
    [animationView playComplete:nil];
    self.animationView = animationView;
    [animationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.width.height.offset(300);
        make.top.offset(KNavBarHight);
    }];

    UILabel *titleLabel = [UILabel lableWithSuperView:self.view font:UIFontMediumMake(24) color:UIColor.tj_333333Color title:@"welcome to Kai" textAlignment:NSTextAlignmentLeft];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(animationView.mas_bottom).offset(8);
        make.centerX.offset(0);
    }];
    
    UILabel *subTitleLabel = [UILabel lableWithSuperView:self.view font:UIFontMake(18) color:UIColor.tj_868391Color title:@"start a bit way to chat!" textAlignment:NSTextAlignmentLeft];
    [subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom);
        make.centerX.offset(0);
    }];
    
    HJStyle2Button *registrationButton = [HJStyle2Button buttonWithSuperView:self.view font:UIFontMediumMake(14) color:nil title:@"Account registration"];
    [registrationButton addTarget:self action:@selector(didClickRgistrationButton) forControlEvents:UIControlEventTouchUpInside];
    [registrationButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.inset(20);
        make.height.offset(55);
        make.bottom.inset(10 + TabbarSafeBottomMargin);
    }];
    
    HJStyle1Button *emailLoginButton = [HJStyle1Button buttonWithSuperView:self.view font:UIFontMediumMake(14) color:nil title:@"Email-login"];
    [emailLoginButton addTarget:self action:@selector(didClickEmailLoginButton) forControlEvents:UIControlEventTouchUpInside];
    [emailLoginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.equalTo(registrationButton);
        make.bottom.equalTo(registrationButton.mas_top).inset(15);
    }];
}

- (void)tapJsonAnimationView {
    [self.animationView playComplete:nil];
}

- (void)loadAgreementData {
    [HJMinePresent getAgreementComplete:nil];
}

- (void)didClickRgistrationButton {
    [self.navigationController pushViewControllerWithName:@"HJRegisterController"];
}

- (void)didClickEmailLoginButton {
    [self.navigationController pushViewControllerWithName:@"HJLoginController"];
    
}

- (BOOL)hiddenBackgroundView {
    return NO;
}

@end
